/*
 * @Author: 王维铭 2061550880@qq.com
 * @Date: 2025-02-28 11:28:43
 * @LastEditors: 王维铭 2061550880@qq.com
 * @LastEditTime: 2025-02-28 14:49:32
 * @FilePath: \盐师22Git仓库\day05\Test05.java
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package day05;

public class Test06 {
    public static void main(String[] args) {
        int [] array = {-1,-2,-3,-4,-8};
        int max = getMax(array);
        System.out.println("该数组的最大值是："+max);
            }
        public static int getMax(int[] arr){
            int max=arr[0];
            //遍历数组
            //int sum = 0;
            for (int i = 0; i<arr.length;i++){
                if(arr [i] > max){
                    max = arr[i];
                }
                System.out.println(arr[i]);
                //sum += arr[i];
            }
            //返回最大值
            
            return max;
        }
    
}
